package com.ruifu.pls.repository;


import com.ruifu.pls.entity.BasSku;
import com.ruifu.pls.entity.BasSkuId;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;
import java.util.List;

public interface SkuRepository
        extends PagingAndSortingRepository<BasSku, BasSkuId>, JpaSpecificationExecutor<BasSku>
{
       @Query(value="SELECT * " +
               "FROM BAS_SKU A " +
               "INNER join BAS_CUSTOMER  B ON  A.CUSTOMERID = B.CUSTOMERID " +
               "AND  A.RESERVEDFIELD05 IS NOT NULL  AND A.edittime > (sysdate-5) and A.CUSTOMERID IS NOT NULL AND A.Descr_C is not NULL  AND A.alternate_Sku1 is not null AND A.Alternate_SKU1 IS NOT NULL and A.ALTERNATE_SKU5 is not null " +
               "ORDER BY A.EDITTIME DESC",nativeQuery=true)
       public List<BasSku> findGBasSku( );

       @Query(value=("SELECT * FROM BAS_SKU where  edittime between to_date(?1, 'YYYY/MM/DD HH24:MI:SS') and to_date(?2, 'YYYY/MM/DD HH24:MI:SS') "),nativeQuery=true)
       public List<BasSku> findByEdittimeBetween(String start, String end);

       public List<BasSku> findByEdittimeIn(List<Date> edittime);

       public List<BasSku> findByEdittime(Date edittime);

       public  List<BasSku>  getBySkuAndCustomerid(String sku , String  customerid);
}
